﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Rodunu.Movies.Logic.Movie
{
    internal static class MovieSearchHelper
    {
        internal static bool CheckIfKeyword(string s)
        {
            switch (s.Trim().ToUpper())
            {
                case "A":
                case "THE":
                case "-":
                case ":":
                case ".":
                case ",":
                case "?":
                    return false;
                default:
                    return true;
            }
        }

        internal static bool IsInteger(string strNumber)
        {
            Regex objNotIntPattern = new Regex("[^0-9-]");
            Regex objIntPattern = new Regex("^-[0-9]+$|^[0-9]+$");

            return !objNotIntPattern.IsMatch(strNumber) &&
            objIntPattern.IsMatch(strNumber);
        }

        internal static bool IsNumeric(string val, System.Globalization.NumberStyles NumberStyle)
        {
            Double result;
            return Double.TryParse(val, NumberStyle, new System.Globalization.CultureInfo
                        ("en-US"), out result);
        }

        internal static bool IsNumber(string number)
        {
            if (IsInteger(number))
                return true;

            if (IsNumeric(number, System.Globalization.NumberStyles.AllowDecimalPoint))
                return true;

            if (IsNumeric(number, System.Globalization.NumberStyles.AllowThousands))
                return true;

            if (IsNumeric(number, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint))
                return true;

            return false;
        }
    }
}
